// const baseUrl='https://dev-gw.dsicm.com/biz/';  //dev
// const baseUrl='http://47.243.20.102:8080/';//sit
const baseUrl='http://www.kucozy.com:8080/';//sit
// http://www.kucozy.com:8080
// http://47.243.20.102:8080/system/info/scan?productId=1002
// const baseUrl='http://192.168.110.104:9999/biz/';//本地

const app = getApp();
export function request(prams) {
	return new Promise((resolve, reject) => {
		let url;
		if(prams.urlData=="id"){
			 url = baseUrl + prams.url+prams.data.id;
		}else{
			 url = baseUrl + prams.url;
		}
		uni.request({
			url: url,
			data: prams.data,
			method: prams.method,
			header: {
				// Authorization: app.globalData.token
				'Content-type': 'application/json;charset=UTF-8',
				
			},
			success: (res) => {		
				console.log(res,"ress");
				if (res.data) {
					resolve(res.data);
					if (res.data.code > 0) {
						uni.showToast({
							title: res.data.message,
							icon: 'none',
							duration: 2000
						})
					}					
					// token 过期或者失效
					if (res.data.status == 401) {						
						uni.hideLoading();
						
					}
					uni.hideLoading()
				} else {
					
				}
			},
			fail: (err) => {
				reject(err);
			},
			complete: () => {
				// console.log('请求完成')
			}
		});
	})
}

